package com.yizhang.sqlSession;

import com.yizhang.config.XmlConfigBuilder;
import com.yizhang.pojo.Configuration;
import org.dom4j.DocumentException;

import java.io.InputStream;

/**
 * @Author: yi.zhang
 * @CreateTime: 2025-05-27 14:15:30
 * @Description: 构建SqlSessionFactory
 */
public class SqlSessionFactoryBuilder {

    /**
     * 创建SqlSessionFactory
     * @param inputStream
     * @return
     * @throws DocumentException
     */
    public SqlSessionFactory build(InputStream inputStream) throws DocumentException {
        XmlConfigBuilder xmlConfigBuilder = new XmlConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parse(inputStream);

        return new DefaultSqlSessionFactory(configuration);
    }
}
